package com.team7.stat.service.impl;

import com.team7.stat.dao.CourseDao;
import com.team7.stat.entity.Course;
import com.team7.stat.service.CourseService;
import com.team7.stat.utils.CommonResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: CourseServiceImpl
 * @Description: 课程 服务实现类
 * @Author: 赵孟阳
 * @Date: 2021/10/19 21:11
 */
@Service
public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements CourseService {
    @Resource
    private CourseDao courseDao;

    @Override
    public CommonResult queryAllCourseRanking(Course course) {
        QueryWrapper<Course> wrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(course.getGmtCreate())){
            wrapper.ge("gmt_modified",course.getGmtCreate());
        }
        if (StringUtils.isNotEmpty(course.getGmtModified())){
            wrapper.le("gmt_modified",course.getGmtModified());
        }

        List<Map> maps = courseDao.queryAllCourseRanking(course);
        return new CommonResult(2000,"查询成功",maps);
    }
}
